package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmChannelDto;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description TODO
 * @Author bo.li
 * @Date 2023/3/16 10:49
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {

    @Autowired
    private WmChannelService wmChannelService;

    @GetMapping("/channels")
    public ResponseResult listAll(){
       return wmChannelService.findAll();
    }
    /**
     * 分页查询所有的频道
     */
    @PostMapping("/list")
    public ResponseResult pageChannel(@RequestBody WmChannelDto wmChannelDto){
        return wmChannelService.PageChannel(wmChannelDto);
    }

    /**
     * 删除频道
     * @param
     * @param id
     * @return
     */
    @GetMapping("/del/{id}")
    public ResponseResult delChannel(@PathVariable Integer id){
        return wmChannelService.delChannl(id);
    }

    /**
     * 修改频道
     * @param wmChannelDto
     * @return
     */
    @PostMapping("/update")
    public ResponseResult updateChannel(@RequestBody WmChannelDto wmChannelDto){
        return wmChannelService.updateChannel(wmChannelDto);
    }
    /**
     * 新增频道
     */
    @PostMapping("/save")
    public ResponseResult saveChannel(@RequestBody WmChannelDto wmChannelDto){
        return wmChannelService.saveChannel(wmChannelDto);
    }
}